import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

const layout = () => import('@/view/layout/layout.vue')
const home = () => import('@/view/home/home.vue')
const topCategory = () => import('@/view/category/category-index.vue')
const subCategory = () => import('@/view/category/sub.vue')
const product = () => import('@/view/product/product.vue')
const login = () => import('@/view/login/login.vue')
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: layout,
    children: [
      {
        path: '/',
        component: home
      },
      {
        path: '/category/:id',
        component: topCategory
      },
      {
        path: '/category/sub/:id',
        component: subCategory
      },
      {
        path: '/product/:id',
        component: product
      },
    ]
  },
  {
    path:'/login',
    component:login
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior() {
    return { top: 0, behavior: 'smooth' }
  }
})
export default router
